﻿using System;

namespace MessagePack.Formatters
{
	// Token: 0x0200005C RID: 92
	public class UriFormatter : IMessagePackFormatter<Uri>
	{
		// Token: 0x0600015F RID: 351 RVA: 0x0000599F File Offset: 0x00003D9F
		private UriFormatter()
		{
		}

		// Token: 0x06000160 RID: 352 RVA: 0x000059A7 File Offset: 0x00003DA7
		public int Serialize(ref byte[] bytes, int offset, Uri value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			return MessagePackBinary.WriteString(ref bytes, offset, value.ToString());
		}

		// Token: 0x06000161 RID: 353 RVA: 0x000059CA File Offset: 0x00003DCA
		public Uri Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			return new Uri(MessagePackBinary.ReadString(bytes, offset, out readSize));
		}

		// Token: 0x04000051 RID: 81
		public static readonly IMessagePackFormatter<Uri> Instance = new UriFormatter();
	}
}
